import akshare as ak


if __name__ == "__main__":
    print(ak.__version__)
    stock_hfq_df = ak.stock_zh_a_hist(
        symbol="002202", adjust="hfq", start_date="20231201", end_date="20231210"
    )
    print(stock_hfq_df)
    print("main----------1--")
    stock_zh_a_hist_df = ak.stock_zh_a_hist(
        symbol="002202",
        period="daily",
        start_date="20231201",
        end_date="20231210",
        adjust="qfq",
    )
    print(stock_zh_a_hist_df)
    print("main----------2--")
    # 利用 AKShare 获取股票的后复权数据，这里只获取前 6 列
    stock_hfq_df = ak.stock_zh_a_hist(
        symbol="002202", adjust="hfq", start_date="20231201", end_date="20231210"
    ).iloc[:, :6]
    # 处理字段命名，以符合 Backtrader 的要求
    stock_hfq_df.columns = [
        "date",
        "open",
        "close",
        "high",
        "low",
        "volume",
    ]
    print("stock_hfq_df", stock_hfq_df)
    print("main----------3--")
    df = ak.stock_zh_a_hist_min_em(
        symbol="002202",
        start_date="2023-12-01 09:30:00",
        end_date="2023-12-10 15:00:00",
        period="30",
        adjust="",
    )

    print(df)
    print("main----------4--")
    df = ak.stock_zh_a_minute(symbol="sz002202", period="30", adjust="qfq")
    print(df)
    print("main----------5--")
    stock_zh_a_hist_min_em_df = ak.stock_zh_a_hist_min_em(
        symbol="000001",
        start_date="2021-09-01 09:32:00",
        end_date="2021-09-06 09:32:00",
        period="5",
        adjust="hfq",
    )
    print(stock_zh_a_hist_min_em_df)


"""
Date, opening, closing, highest, lowest,

turnover

Transaction volume,

Amplitude,

Price fluctuations,

Price fluctuations,

Turnover rate

Open_Price, close_Price, highest_Price, lowest_Price, trade_Volume,
"""
